<% if false # the license inside this if block assertains to this file -%>
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
<% end -%>
<%= compile 'templates/license.erb' -%>

<%= lines(autogen_notice :ruby) -%>

<%
def data_to_constant(name, data)
  if data.any? { |d| d.include?(' ') }
    [
      "#{name} = [",
      indent_list(data, 2),
      '].freeze'
    ]
  else
    [
      "#{name} = %w[",
      indent_list(data, 2).tr("'", '').tr(',', ''),
      '].freeze'
    ]
  end
end
-%>
<%
  var_map = @constants.value_arrays(@api).map do |name, info|
    source = info[:source]
    if source.size == 1
      [
        "# Constants for: #{source.first.map { |s| s.to_s }.join('.')}",
        data_to_constant(name, info[:data])
      ]
    else # source.size == 1
      [
        '# Constants for the following objects:',
        source.map do |ss|
          t = ss.map { |s| s.to_s }.join('.')
          "\# - #{t}"
        end,
        data_to_constant(name, info[:data])
      ]
    end # source.size == 1
  end # @constants.value_arrays(@api).each
-%>
module GoogleTests
<%= lines(indent(emit_rubocop(binding, :module,
                              %w[GoogleTests Constants].join('::'), :disabled),
          2)) -%>
  module Constants
<%= lines(indent(var_map.map { |v| lines(v) }.join("\n"), 4)) -%>
  end
<%= lines(indent(emit_rubocop(binding, :module,
                              %w[GoogleTests Constants].join('::'), :enabled),
          2)) -%>
end
